package com.Util;

import java.beans.Statement;
import java.sql.Connection;

public class DB {
    protected final static String URL = "jdbc:mysql://localhost:3306/hw?useSSL=false&&rewriteBatchedStatements=true";
    protected final static String USER = "root";
    protected final static String PWD = "123456";
    protected final static String DBUSER = "user";
    protected final static String DBIMAGE = "image";
    protected final static String DBTK="ticket";
    protected final static String DBMESS="message";
    protected final static String DBSERVER="server";
    protected final static String DBIP="ip";
    public static boolean debug = true;
    public static boolean jsptest = false;

    public static boolean isDebug(){
        return debug;
    }

    static void connector(){
        try{
            Class.forName("com.mysql.cj.jdbc.Driver");
        }catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

    //断开数据库
    public void close(Statement stmt, Connection con) throws Exception {
        if(stmt!=null) {
            con.close();
        }
        if(con!=null) {
            con.close();
        }
    }

    public void setDebug() {
        this.debug = true;
    }

    public static String getURL() {
        return URL;
    }

    public static String getUSER() {
        return USER;
    }

    public static String getPWD() {
        return PWD;
    }
}
